package com.alibaba.aone.casestudy.module.action;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;

import com.alibaba.citrus.turbine.Context;
import com.alibaba.fastjson.JSONObject;

public class AsyncAction {
	
	@Autowired
	private HttpServletResponse response;
	@Autowired
	private HttpServletRequest request;
	
	public void doComment(Context context) throws IOException{
		System.out.println("yes, you get comment!");
		System.out.println(request.getParameter("pass"));
		JSONObject attach = new JSONObject();
		attach.put("at1", "atv1");
		attach.put("second", "apple");
		attach.put("third", "pie");
		JSONObject ret = new JSONObject();
		ret.put("name", "zll");
		ret.put("email", "foxmail");
		ret.put("attach", attach);
		//context.put("return", ret);
		PrintWriter writer = response.getWriter();
		writer.println(ret);
		//context.put("actionContext", "gotit");
		System.out.println("action: "+context.hashCode());
	}
}
